from datetime import datetime

from backend_server import db


class TestCase(db.Model):
    """
    测试用例表，数据会生成test_case表
    """
    id = db.Column(db.Integer, primary_key=True)
    nodeid = db.Column(db.String(80), unique=True, nullable=False)
    description = db.Column(db.String(120), unique=False, nullable=True)
    # create_at = db.Column(db.DateTime, default=datetime.now)
    # update_at = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now)
    def as_dict(self):
        """
        返回测试用例的数据
        ：retrun:
        """
        return {"id": self.id, "nodeid": self.nodeid, "description": self.description}

if __name__ == '__main__':
    # 全部删除再创建, 需要migrate进行优化（？？）
    db.drop_all()
    db.create_all()